package com.ltkj.shop.service.impl;

import java.util.List;
import com.ltkj.common.core.utils.DateUtils;
import com.ltkj.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ltkj.shop.mapper.ShopGoodsSpecMapper;
import com.ltkj.shop.domain.ShopGoodsSpec;
import com.ltkj.shop.service.IShopGoodsSpecService;

/**
 * 商品规格Service业务层处理
 * 
 * @author xupf
 * @date 2023-08-30
 */
@Service
public class ShopGoodsSpecServiceImpl implements IShopGoodsSpecService 
{
    @Autowired
    private ShopGoodsSpecMapper shopGoodsSpecMapper;

    /**
     * 查询商品规格
     * 
     * @param id 商品规格主键
     * @return 商品规格
     */
    @Override
    public ShopGoodsSpec selectShopGoodsSpecById(Long id)
    {
        return shopGoodsSpecMapper.selectShopGoodsSpecById(id);
    }

    /**
     * 查询商品规格列表
     * 
     * @param shopGoodsSpec 商品规格
     * @return 商品规格
     */
    @Override
    public List<ShopGoodsSpec> selectShopGoodsSpecList(ShopGoodsSpec shopGoodsSpec)
    {
        return shopGoodsSpecMapper.selectShopGoodsSpecList(shopGoodsSpec);
    }

    /**
     * 新增商品规格
     * 
     * @param shopGoodsSpec 商品规格
     * @return 结果
     */
    @Override
    public int insertShopGoodsSpec(ShopGoodsSpec shopGoodsSpec)
    {
        shopGoodsSpec.setCreateTime(DateUtils.getNowDate());
        shopGoodsSpec.setCreateBy(SecurityUtils.getLoginUser().getUsername());
        return shopGoodsSpecMapper.insertShopGoodsSpec(shopGoodsSpec);
    }

    /**
     * 修改商品规格
     * 
     * @param shopGoodsSpec 商品规格
     * @return 结果
     */
    @Override
    public int updateShopGoodsSpec(ShopGoodsSpec shopGoodsSpec)
    {
        shopGoodsSpec.setUpdateTime(DateUtils.getNowDate());
        shopGoodsSpec.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
        return shopGoodsSpecMapper.updateShopGoodsSpec(shopGoodsSpec);
    }

    /**
     * 批量删除商品规格
     * 
     * @param ids 需要删除的商品规格主键
     * @return 结果
     */
    @Override
    public int deleteShopGoodsSpecByIds(Long[] ids)
    {
        return shopGoodsSpecMapper.deleteShopGoodsSpecByIds(ids);
    }

    /**
     * 删除商品规格信息
     * 
     * @param id 商品规格主键
     * @return 结果
     */
    @Override
    public int deleteShopGoodsSpecById(Long id)
    {
        return shopGoodsSpecMapper.deleteShopGoodsSpecById(id);
    }
}
